package minefak3r;

/**
 *
 * @author Chriss & D4rky!
 */
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;

class ServerReader extends Thread {

    DataInputStream dis;
    DataOutputStream dos;
    boolean sendData = true;
    boolean sendnewSpawn;

    public ServerReader(Socket client, Socket target) throws Exception {
        dis = new DataInputStream(target.getInputStream());
        dos = new DataOutputStream(client.getOutputStream());
    }

    @Override
    public void run() {
        try {
            while (true) {
                Thread.sleep(1);
                int bytes = dis.available();
                if (bytes > 0) {
                    byte packID = dis.readByte();
                    switch (packID) {
                    }
                    if (sendData) {
                        bytes = dis.available();
                        byte data[] = new byte[bytes];
                        dis.readFully(data);
                        dos.writeByte(packID);
                        dos.write(data);
                    }
                }
                sendData = true;
            }
        } catch (Exception e) {
            e.printStackTrace(System.err);
        }
    }
}